<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<script type="text/javascript" src="js/jquery.itextclear.js"></script>
<script type="text/javascript">
	$(document)
			.ready(
					function() {
						$(
								'input[type=text], input[type=password], input[type=url], input[type=email], input[type=number], textarea',
								'.form').iTextClear();
					});
</script>
<!-- jQplot CSS -->

<link rel="stylesheet" media="screen" href="css/Tree.css" />
<!-- jQplot CSS END -->

<!-- DATATABLES CSS -->
<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css" />
<!-- DATATABLES CSS END -->
<s:if test="#request.category != null && #request.category.id > 0">
	<h1 class="page-title">培训类别设定 - 修改</h1>
</s:if>
<s:else>
	<h1 class="page-title">培训类别设定 - 添加</h1>
</s:else>
<div class="container_12 clearfix leading">
	<div class="side grid_12 leading">
		<form id="post_form" name="post_form" class="form has-validation">
			<s:if test="#request.category != null && #request.category.id > 0">
				<input type="hidden" name="category.id" value="${category.id}" />
			</s:if>
			<input type="hidden" name="category.organization.id"
				value="${category.organization.id}" />
			<div class="clear"></div>
			<div class="clearfix">

				<label for="form-email" class="form-label">培训类型 <em>*</em></label>

				<div class="form-input">
					<input type="text" id="title" name="category.title"
						value="${category.title}" required="required"
						placeholder="请输入培训类型名称" />
				</div>

			</div>

			<div class="clearfix"></div>
			<div class="form-action clearfix">
				<button class="button" type="button" onclick="checkForm()">
					<s:if test="#request.category.id > 0">修改</s:if>
					<s:else>添加</s:else>
				</button>
				<button class="button" type="reset">重置</button>
				<a class="button" href="javascript:void(0)"
					onclick="javascript:history.back()"><span
					style="background: url(${ctx}/images/img/arrow_undo.png)"
					class="icon">&nbsp;</span>返回</a>

			</div>

		</form>
	</div>
</div>

<div class="clear"></div>

<script type="text/javascript">
	function checkForm() {
		if ($("#title").val() == null || $("#title").val() == "") {
			alert("请输入培训类型名称");
			return;
		}

		var url = "${ctx}/train/post_category.xhtml";
		$.ajax(
			url,
			{
				type : "POST",
				data : $("#post_form").serialize(),
				dataType : "html",
				cache : false,
				success : function(a) {
					alert("提交成功");
					window.location.href = "${ctx}/index.xhtml#train/category_main.xhtml?organizationId=${category.organization.id}";
				},
				error : function(XMLHttpRequest, textStatus,
						errorThrown) {
					alert('提交申请发生异常');
				},
				complete : function() {
				}
			});

	}

	
</script>